package com.gccloud.design;

import com.gccloud.design.entity.SdRepoLimitTimeEntity;
import com.gccloud.design.service.LimitTimeConfigService;
import com.gccloud.starter.common.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiSort;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 环节时限设置
 *
 * @author 冯海琴
 */
@Slf4j
@RestController
@RequestMapping("/limitTimeConfig")
@Api(tags = "环节时限设置API")
@ApiSort(value = 12)
public class LimitTimeConfigController {

    @Resource
    private LimitTimeConfigService limitTimeConfigService;

    /**
     * 环节时限设置：添加环节时限
     *
     * @param sdRepoLimitTimeEntity 环节时限配置实体
     * @return R<Boolean>
     */
    @ApiOperation(value = "添加环节时限")
    @RequestMapping(value = "/addLimitTime", method = RequestMethod.POST)
    public R<Boolean> addLimitTime(@RequestBody SdRepoLimitTimeEntity sdRepoLimitTimeEntity) {
        limitTimeConfigService.addLimitTime(sdRepoLimitTimeEntity);
        return R.success();
    }

    /**
     * 环节时限设置：获取当前环节的环节时限
     *
     * @param sdRepoLimitTimeEntity 环节时限配置实体
     * @return R<List < SdRepoLimitTimeEntity>>
     */
    @ApiOperation(value = "获取当前环节的环节时限")
    @GetMapping(value = "/getTimeLimit")
    public R<List<SdRepoLimitTimeEntity>> getTimeLimit(SdRepoLimitTimeEntity sdRepoLimitTimeEntity) {
        List<SdRepoLimitTimeEntity> list = limitTimeConfigService.getTimeLimit(sdRepoLimitTimeEntity);
        return R.success(list);
    }
}

